package com.scsj.supermarket.presenter;

import android.util.Log;

import com.orhanobut.logger.Logger;
import com.scsj.supermarket.base.AuthenticationBase;
import com.scsj.supermarket.base.GetTradeRecordListBase;
import com.scsj.supermarket.bean.BaseBean;
import com.scsj.supermarket.bean.GetTradeRecordListBean;
import com.scsj.supermarket.model.AuthenticationModel;
import com.scsj.supermarket.model.GetTradeRecordListModel;

import dkmvp.mvp.BasePresenter;
import dkmvp.net.ResponseCallback;
import okhttp3.RequestBody;

/**
 * 交易流水账单列表分页查询  余额明细presenter
 */

public class GetTradeRecordListPresenter extends BasePresenter implements GetTradeRecordListBase.IPresenter {

    private GetTradeRecordListBase.IModel mModel;
    private GetTradeRecordListBase.IView mView;

    public GetTradeRecordListPresenter(GetTradeRecordListBase.IView view) {
        mView = view;
        mModel = new GetTradeRecordListModel();
    }


    @Override
    public void deliverData(RequestBody requestBody) {
        addSubscription(mModel.getData(requestBody, new ResponseCallback<GetTradeRecordListBean>() {
            @Override
            public void onSuccess(GetTradeRecordListBean result) {
                if (result.getStatusCode() == 200) {
                    mView.showSuccessMsg("获取余额明细成功", result);
                } else {
                    mView.showErrorMsg(result.getMsg());
                }
            }

            @Override
            public void onFaild(String msg) {
                mView.showErrorMsg(msg);
                Log.e("获取余额明细onFaild", msg + "");
            }
        }));
    }


}
